package cn.powertime.evaluation.web.controller;


import cn.powertime.evaluation.facade.DbqNewsFacade;
import cn.powertime.evaluation.vo.ParamPageVo;
import cn.powertime.evaluation.vo.WebReqNewsSearchVo;
import cn.powertime.evaluation.vo.WebRespNewsListVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 广告/新闻表 前端控制器
 * </p>
 *
 * @author liqi
 * @since 2019-09-23
 */
@RestController
@RequestMapping("/web/dbq-news")
@Api(value = "/web/dbq-news", tags = "广告/新闻/公告接口", produces = MediaType.ALL_VALUE)
public class DbqNewsController extends BaseController {

    @Autowired
    private DbqNewsFacade dbqNewsFacade;

    @ApiOperation(value = "新闻列表",response = WebRespNewsListVo.class)
    @PostMapping(value = "/newsList")
    public Object list(@Validated @RequestBody ParamPageVo<WebReqNewsSearchVo> vo) {
        IPage<WebRespNewsListVo> list = dbqNewsFacade.newsList(vo);
        return success(list);
    }

    @ApiOperation(value = "查看详情")
    @GetMapping(value = "/details/{newsId}")
    @ApiImplicitParam(name = "newsId", value = "新闻ID", required = true, dataType = "Long")
    public Object chapterList(@PathVariable("newsId") @NotNull(message = "新闻id不能为空") Long newsId) {
        WebRespNewsListVo b = dbqNewsFacade.details(newsId);
        return success(b);
    }

}
